/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ipfms.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author fikri
 */
@Entity
@Table(name = "building")
public class Building implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_building")
    private Integer idBuilding;
    @Column(name = "building_name")
    private String buildingName;
    @Column(name = "building_add1")
    private String buildingAdd1;
    @Column(name = "building_add2")
    private String buildingAdd2;
    @Column(name = "building_add3")
    private String buildingAdd3;
    @Column(name = "building_add4")
    private String buildingAdd4;
    @Column(name = "building_postcode")
    private String buildingPostcode;
    
    @Column(name = "total_floor")
    private Integer totalFloor;
    
    @Column(name = "max_unit_per_floor")
    private Integer maxUnitPerFloor;
    
    @Column(name = "year_of_completion")
    private String yearCompletion;
    
      @Column(name = "build_up")
    private Integer buildUp;
    
    @ManyToOne (fetch = FetchType.LAZY)
    @JoinColumn (name = "building_state")
    private KodNegeri buildingState;
    
    @ManyToOne (fetch = FetchType.LAZY)
    @JoinColumn (name = "building_type")
    private KodJenisBangunan buildingType;
    @Column(name = "amt_rent")
    private Long amtRent;
    @Column(name = "amt_sell")
    private Long amtSell;
    @Basic(optional = false)
    @Column(name = "active")
    private char active;
    
    @Column(name = "publish")
    private char publish;
    
    @Column(name = "building_desc")
    private String buidingDesc;
    
    
    @Column(name = "map_location")
    private String mapLocation;
    
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "building")
    private List<BuildingImg> buildingImgList;
    
    @Embedded
    private InfoAudit infoAufit;

    public Building() {
    }

    public Building(Integer idBuilding) {
        this.idBuilding = idBuilding;
    }

    public Building(Integer idBuilding, KodJenisBangunan buildingType, char active) {
        this.idBuilding = idBuilding;
        this.buildingType = buildingType;
        this.active = active;        
    }

    public Integer getIdBuilding() {
        return idBuilding;
    }

    public void setIdBuilding(Integer idBuilding) {
        this.idBuilding = idBuilding;
    }

    public String getBuildingName() {
        return buildingName;
    }

    public void setBuildingName(String buildingName) {
        this.buildingName = buildingName;
    }

    public String getBuildingAdd1() {
        return buildingAdd1;
    }

    public void setBuildingAdd1(String buildingAdd1) {
        this.buildingAdd1 = buildingAdd1;
    }

    public String getBuildingAdd2() {
        return buildingAdd2;
    }

    public void setBuildingAdd2(String buildingAdd2) {
        this.buildingAdd2 = buildingAdd2;
    }

    public String getBuildingAdd3() {
        return buildingAdd3;
    }

    public void setBuildingAdd3(String buildingAdd3) {
        this.buildingAdd3 = buildingAdd3;
    }

    public String getBuildingAdd4() {
        return buildingAdd4;
    }

    public void setBuildingAdd4(String buildingAdd4) {
        this.buildingAdd4 = buildingAdd4;
    }

    public String getBuildingPostcode() {
        return buildingPostcode;
    }

    public void setBuildingPostcode(String buildingPostcode) {
        this.buildingPostcode = buildingPostcode;
    }

    public KodNegeri getBuildingState() {
        return buildingState;
    }

    public void setBuildingState(KodNegeri buildingState) {
        this.buildingState = buildingState;
    }

    public KodJenisBangunan getBuildingType() {
        return buildingType;
    }

    public void setBuildingType(KodJenisBangunan buildingType) {
        this.buildingType = buildingType;
    }

    public Long getAmtRent() {
        return amtRent;
    }

    public void setAmtRent(Long amtRent) {
        this.amtRent = amtRent;
    }

    public Long getAmtSell() {
        return amtSell;
    }

    public void setAmtSell(Long amtSell) {
        this.amtSell = amtSell;
    }

    public char getActive() {
        return active;
    }

    public void setActive(char active) {
        this.active = active;
    }

    public char getPublish() {
        return publish;
    }

    public void setPublish(char publish) {
        this.publish = publish;
    }

    public String getBuidingDesc() {
        return buidingDesc;
    }

    public void setBuidingDesc(String buidingDesc) {
        this.buidingDesc = buidingDesc;
    }

     

    public Integer getMaxUnitPerFloor() {
        return maxUnitPerFloor;
    }

    public void setMaxUnitPerFloor(Integer maxUnitPerFloor) {
        this.maxUnitPerFloor = maxUnitPerFloor;
    }

    public Integer getTotalFloor() {
        return totalFloor;
    }

    public void setTotalFloor(Integer totalFloor) {
        this.totalFloor = totalFloor;
    }

    public String getYearCompletion() {
        return yearCompletion;
    }

    public void setYearCompletion(String yearCompletion) {
        this.yearCompletion = yearCompletion;
    }

    public Integer getBuildUp() {
        return buildUp;
    }

    public void setBuildUp(Integer buildUp) {
        this.buildUp = buildUp;
    }

    public InfoAudit getInfoAufit() {
        return infoAufit;
    }

    public void setInfoAufit(InfoAudit infoAufit) {
        this.infoAufit = infoAufit;
    }

    public String getMapLocation() {
        return mapLocation;
    }

    public void setMapLocation(String mapLocation) {
        this.mapLocation = mapLocation;
    }

    @XmlTransient
    public List<BuildingImg> getBuildingImgList() {
        return buildingImgList;
    }

    public void setBuildingImgList(List<BuildingImg> buildingImgList) {
        this.buildingImgList = buildingImgList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idBuilding != null ? idBuilding.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Building)) {
            return false;
        }
        Building other = (Building) object;
        if ((this.idBuilding == null && other.idBuilding != null) || (this.idBuilding != null && !this.idBuilding.equals(other.idBuilding))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ipfms.model.Building[ idBuilding=" + idBuilding + " ]";
    }
    
}
